package chapter4.No4_1_使用reentrantLock类.demo15;

/**
 * *：
 *    方法lockInterruptibly():如果当前线程未被中断，则获取锁定，
 *        如果已经被中断则出现异常
 *    备注：lockInterrupttibly()遇见interrupt会报异常
 * Created by Administrator on 2016/11/22.
 */
public class Main2 {
    public static void main(String[] args) throws InterruptedException {
        final ServiceClass2 sc = new ServiceClass2();
        Runnable runnable = new Runnable() {
            public void run() {
                sc.methodA();
            }
        };
        Thread a = new Thread(runnable);
        a.setName("a");
        a.start();
        Thread.sleep(100);
        Thread b = new Thread(runnable);
        b.setName("b");
        b.start();
        b.interrupt();
        System.out.println("main end");
    }
}
